import { ref } from 'vue';
import { GameKernel, EVENTS } from '../game';

const kernel = GameKernel.inst;

const state = ref(kernel.storyModel.uiState);

kernel.bus.on(EVENTS.STORY_STATE_UPDATE, () => {
  state.value = kernel.storyModel.uiState;
});
kernel.bus.on(EVENTS.GAME_LOADED, () => {
  state.value = kernel.storyModel.uiState;
});

export function useStory() {
  state.value = kernel.storyModel.uiState;
  return { state };
}
